﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace RTS_RPG
{
    public class Overworld_Loader
    {
        public Overworld_TextureManager textures;
        public PlayerStats pstats;
        public String overworld_name;

        public Overworld_Loader(String _overworld_name, Overworld_TextureManager _textures, PlayerStats _pstats)
        {
            overworld_name = _overworld_name;
            textures = _textures;
            pstats = _pstats;
        }

        public List<Site> find_overworld_sites(IServiceProvider services)
        {
            List<Site> places = new List<Site>();
            switch (overworld_name)
            {
                case "test_world":
                    List<Area> areas = new List<Area>();
                    Vector2 temp = new Vector2(400, 200);
                    Vector2 NaN = new Vector2(Program.NaN, Program.NaN);

                    List<Vector2> coords = new List<Vector2>();
                    coords.Add(temp);
                    areas.Add(new Area("test_area", new GameMap(null, NaN, null), coords, pstats, services));

                    temp.X = 300;
                    temp.Y = 400;
                    places.Add(new Site("test_area", textures.town_sprite, areas[0], temp));
                    break;
                default:
                    break;
            }
            return places;
        }

        public List<Overworld_Creature> find_overworld_creatures(Vector2 open_creature_location)
        {
            List<Overworld_Creature> creatures = new List<Overworld_Creature>();
            switch(overworld_name) 
            {
                case "test_world":
                    Vector2 checker;
                    for (int i = 0; i < 4; ++i)
                    {
                        checker = new Vector2(200 * (i + 1), 500);
                        if (checker == open_creature_location) continue;
                        bool vertical = true;
                        if (i % 2 > 0) vertical = false;
                        creatures.Add(new Overworld_Creature(8, checker, 50, vertical, pstats.textures));
                    }
                    break;
                default:
                    break;
            }
            return creatures;
        }
    }
}
